<!--
 * @Description: 文件描述
 * @Author: 1+
 * @Date: 2024-03-21 09:04:42
 * @LastEditors: 1+
 * @LastEditTime: 2024-04-17 19:31:45
-->
<template>
  <Preview :key="key" />
</template>

<script>
import Preview from './preview'
export default {
  components: {
    Preview
  },
  data(){
    return{
      key:Date.now()
    }
  },
  mounted () {
    // 数据变更 -> 组件销毁重建
    try {
      const listenerArr = ['preview','SaveJSON']
      listenerArr.forEach(item => {
        if (!window.opener || !window.opener.addEventListener) return
        window.opener.addEventListener(item, async (e) => {
          sessionStorage.setItem('chartList', JSON.stringify([{ ...e.detail }]))
          this.key = Date.now()
        })
      })
    } catch (error) {
      console.log(error)
    }
  }
}
</script>

<style>
</style>